package org.gd.hellojavacore.tests;

import java.util.concurrent.atomic.AtomicInteger;

import static java.lang.Thread.sleep;

/**
 * @author Gorhover
 * @since 2013-09-24 09:38
 */
public class LoopTest {

    public static void main(String[] args) {
        try {
            AtomicInteger i = new AtomicInteger(10);
            for(sleep(getTimeout());;sleep(getTimeout())) {
                if(i.get() == 0) {
                    break;
                }
                System.out.println(i.decrementAndGet());
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.exit(0);
    }

    private static long getTimeout() {
        return 500L;
    }
}
